package com.woniuxy.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebUploadConfig implements WebMvcConfigurer {

    @Value("${upload.path}")
    private String uploadPath; //上传服务地址
    /**
     * 添加资源的处理：
     * 注册一些访问地址，如果访问资源是以 /file/开头的路径，就到E:/Temp/这个目
     录下去找
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/file/**").addResourceLocations("file:"+uploadPath);
    }
}
